/*
package com.ruoyi.config;

import com.alibaba.fastjson2.JSON;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.utils.CoordinateUtils;
import com.ruoyi.rabbitmq.RabbitMQMessageVo;
import com.ruoyi.work.domain.TbLocationUser;
import com.ruoyi.work.service.ITbLocationUserService;
import lombok.extern.slf4j.Slf4j;
import net.bytebuddy.implementation.bytecode.Throw;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Slf4j
@Component
@RabbitListener(queues = "${app.rabbitmq.queue}")
public class RabbitmqMessageConsumer {

    private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");

    private volatile int processedCount = 0;
    private volatile LocalDateTime lastProcessTime;

    @Autowired
    private ITbLocationUserService tbLocationUserService;
    @Autowired
    private RedisCache redisCache;

    */
/**
     * 处理接收到的消息 - 单一消费者
     *//*

    @RabbitHandler
    public void handleMessage(RabbitMQMessageVo message) {
        processedCount++;
        lastProcessTime = LocalDateTime.now();

        String currentTime = LocalDateTime.now().format(formatter);

        log.info("=== 开始处理消息 ===");
        */
/*log.info("处理时间: {}", currentTime);
        log.info("消息ID: {}", message.getId());
        log.info("发送者: {}", message.getSender());
        log.info("消息优先级: {}", message.getPriority());
        log.info("已处理消息总数: {}", processedCount);*//*

        log.info("消息内容: {}", message.getContent());
        TbLocationUser locationUser = JSON.parseObject(message.getContent(), TbLocationUser.class);
        if (redisCache.hasKey(locationUser.getWorkNo())){

            double[] locatin = CoordinateUtils.wgs84ToGcj02(Double.parseDouble(locationUser.getLongitude()),Double.parseDouble(locationUser.getLatitude()));
            System.out.println("获取的数据："+locatin);
            if (locatin != null){
                locationUser.setLongitude(String.valueOf(locatin[0]));
                locationUser.setLatitude(String.valueOf(locatin[1]));
            }
            tbLocationUserService.save(locationUser);
        }else{
            throw new RuntimeException("任务已结束，定位信息停至采集！");
        }
        // 模拟业务处理时间
        //simulateBusinessProcessing();
        log.info("=== 消息处理完成 ===\n");
    }

    */
/**
     * 模拟业务处理（耗时操作）
     *//*

    private void simulateBusinessProcessing() {
        try {
            // 模拟处理时间 1-3秒
            int processTime = 1000 + (int)(Math.random() * 2000);
            log.info("业务处理中，预计耗时: {}ms", processTime);
            Thread.sleep(processTime);
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            log.error("处理过程被中断");
        }
    }

    */
/**
     * 获取消费统计信息
     *//*

    public String getConsumerStats() {
        String lastTime = lastProcessTime != null ? lastProcessTime.format(formatter) : "暂无";
        return String.format("已处理消息: %d, 最后处理时间: %s", processedCount, lastTime);
    }
}
*/
